home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / pluginy Firefox / 58519 / 58519.xpi / chrome / nasatabs.jar / content / script.js < prev    next >
Text File  |  2010-01-25  |  5KB  |  73 lines

  1. var NasaTabsPref = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
  2. var NasaTabs = {
  3.    init: function() {
  4.       var getTheme = NasaTabsPref.getCharPref("general.skins.selectedSkin");
  5.         var tabNasa = NasaTabsPref.getBoolPref("extensions.nasatabs.shownasa");
  6.         var favNasa = NasaTabsPref.getBoolPref("extensions.nasatabs.hidenasafav");
  7.         var tabNoia = NasaTabsPref.getBoolPref("extensions.nasatabs.shownoia");
  8.         var tabNoia2 = NasaTabsPref.getBoolPref("extensions.nasatabs.shownoia2");
  9.         var favNoia = NasaTabsPref.getBoolPref("extensions.nasatabs.hidenoiafav");
  10.          var sss = Components.classes["@mozilla.org/content/style-sheet-service;1"].getService       (Components.interfaces.nsIStyleSheetService);
  11.      var thisCSS1 = "chrome://nasatabs/skin/common.css"; var thisCSS2 = "chrome://nasatabs/skin/nasa.css";
  12.       var thisCSS3 = "chrome://nasatabs/skin/shownasa.css"; var thisCSS4 = "chrome://nasatabs/skin/noia.css";
  13.       var thisCSS5 = "chrome://nasatabs/skin/noia2.css"; var thisCSS6 = "chrome://nasatabs/skin/shownoia.css";
  14.      var thisCSS7 = "chrome://nasatabs/skin/shownoia2.css";
  15.       var ios = Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService);
  16.       var commonTheme = ios.newURI(thisCSS1, null, null); var nasaTheme = ios.newURI(thisCSS2, null, null);
  17.       var showNasa = ios.newURI(thisCSS3, null, null); var noiaTheme = ios.newURI(thisCSS4, null, null);
  18.       var noia2Theme = ios.newURI(thisCSS5, null, null); var showNoia = ios.newURI(thisCSS6, null, null);
  19.       var showNoia2 = ios.newURI(thisCSS7, null, null);
  20.     if (getTheme == "nasanightlaunch" && tabNasa) {sss.loadAndRegisterSheet(commonTheme, sss.USER_SHEET);
  21.          sss.loadAndRegisterSheet(nasaTheme, sss.USER_SHEET);
  22.        if (favNasa) {sss.loadAndRegisterSheet(showNasa, sss.USER_SHEET);}}  
  23.     if (getTheme == "Noia2f" && tabNoia) {sss.loadAndRegisterSheet(commonTheme, sss.USER_SHEET);
  24.          sss.loadAndRegisterSheet(noiaTheme, sss.USER_SHEET);
  25.        if(favNoia) {sss.loadAndRegisterSheet(showNoia, sss.USER_SHEET);}} 
  26.     if (getTheme == "Noia2f" && tabNoia2) {sss.loadAndRegisterSheet(commonTheme, sss.USER_SHEET);
  27.          sss.loadAndRegisterSheet(noia2Theme, sss.USER_SHEET);
  28.        if (favNoia) {sss.loadAndRegisterSheet(showNoia2, sss.USER_SHEET);}}
  29.    },
  30.    init2: function () {
  31.       try {var a = document.getElementById("nasa_1"); var b = document.getElementById("nasaFav");
  32.        var c = document.getElementById("noia_1"); var d = document.getElementById("noia_2");
  33.        var e = document.getElementById("noiaFav");
  34.        b.disabled = !a.checked;
  35.        if (c.checked || d.checked) {e.setAttribute("disabled", "false");
  36.        } else {e.setAttribute("disabled", "true");} 
  37.     } catch(ex) {}
  38.    },
  39.    on_Nasa: function() {
  40.     var a = document.getElementById("nasa_1"); var b = document.getElementById("nasaFav");
  41.     b.disabled = !a.checked;
  42.    },
  43.    on_Noia: function() {
  44.     var c = document.getElementById("noia_1"); var d = document.getElementById("noia_2");
  45.     var e = document.getElementById("noiaFav");
  46.     c.checked = c.checked; d.setAttribute("checked", false);
  47.     if (c.checked || d.checked) {e.setAttribute("disabled", "false");} else {e.setAttribute("disabled", "true");} 
  48.    },
  49.    on_Noia2: function() {
  50.     var c = document.getElementById("noia_1"); var d = document.getElementById("noia_2");
  51.     var e = document.getElementById("noiaFav");
  52.     d.checked = d.checked; c.setAttribute("checked", "false");
  53.     if (c.checked || d.checked) {e.setAttribute("disabled", "false");} else {e.setAttribute("disabled", "true");} 
  54.    },
  55.    on_Restart: function() {
  56.         var appStartup = Components.interfaces.nsIAppStartup; var a = document.getElementById("nasa_1");
  57.     var b = document.getElementById("nasaFav"); var c = document.getElementById("noia_1");
  58.     var d = document.getElementById("noia_2"); var e = document.getElementById("noiaFav");
  59.          NasaTabsPref.setBoolPref("extensions.nasatabs.shownasa", a.checked);
  60.        NasaTabsPref.setBoolPref("extensions.nasatabs.hidenasafav", b.checked);
  61.         NasaTabsPref.setBoolPref("extensions.nasatabs.shownoia", c.checked);
  62.         NasaTabsPref.setBoolPref("extensions.nasatabs.shownoia2", d.checked);
  63.         NasaTabsPref.setBoolPref("extensions.nasatabs.hidenoiafav", e.checked);
  64.     b.disabled = !d;
  65.     if (c.checked || d.checked) {e.setAttribute("disabled", "false");} else {e.setAttribute("disabled", "true");} 
  66.         Components.classes["@mozilla.org/toolkit/app-startup;1"].getService(appStartup).quit
  67.        (appStartup.eRestart | appStartup.eAttemptQuit);
  68.         return true;
  69.    }
  70. }
  71. window.addEventListener("load", function() {NasaTabs.init();}, false);
  72. window.addEventListener("load", function() {NasaTabs.init2();}, false);
  73.